﻿<%@ Page Language="c#" CodeBehind="sellman.aspx.cs" AutoEventWireup="false" Inherits="UDS.SubModule.CM.Stat.SellManPage" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
  <title>sellman</title>
  <uds:Style runat="server" Href="~/css/BasicLayout.css" />
  <script language="JavaScript" src="../../../Css/meizzDate.js"></script>
  <script language="javascript">
  //<!--
  function fillstring(str)
  {
	  if(str.length==1)
	  {
		  str = "0" + str; 
	  }
	  return(str);
  }

  function quickseldate(type)
  {
	  var begintime,endtime;
	  var oneminute = 60*1000;
	  var onehour   = 60*oneminute;
	  var oneday    = 24*onehour;
	  var oneweek   = 7*oneday;
  	
	  var todayDate = new Date();
	  var date = todayDate.getDate();
	  var month= todayDate.getMonth() +1;
	  var year= todayDate.getYear();
	  var day = todayDate.getDay();
	  if(navigator.appName == "Netscape")
	  {
		  year = 1900 + year;
	  }

	  if(type=="day")
	  {
		  begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
		  endtime = begintime;
	  }
	  else if(type=="week")
	  {
		  var daytoMon = day-1;
		  if(day==0) 
			  daytoMon = 6;
  		
		  todayDate.setTime(todayDate.getTime()-daytoMon*oneday);
		  date = todayDate.getDate();
		  month= todayDate.getMonth() +1;
		  year= todayDate.getYear();
		  day = todayDate.getDay();
  		
		  begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
  		
		  todayDate.setTime(todayDate.getTime()+6*oneday);
  		
		  date = todayDate.getDate();
		  month= todayDate.getMonth() +1;
		  year= todayDate.getYear();
  		
		  endtime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
	  }
	  else if(type=="month")
	  {
		  var dateto1 = date-1;
  		
		  todayDate.setTime(todayDate.getTime()-dateto1*oneday);
		  date = todayDate.getDate();
		  month= todayDate.getMonth() +1;
		  year= todayDate.getYear();
		  day = todayDate.getDay();
  		
		  begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
  		
		  todayDate.setMonth(month);
		  todayDate.setTime(todayDate.getTime()-oneday);
  		
		  date = todayDate.getDate();
		  month= todayDate.getMonth() +1;
		  year= todayDate.getYear();
  		
		  endtime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());

	  }

	  document.getElementById("tbx_begintime").value = begintime;
	  document.getElementById("tbx_endtime").value = endtime;
  }
  //-->
  </script>
</head>
<body ms_positioning="GridLayout">
  <form id="sellman" method="post" runat="server">
    <table id="Table1" cellspacing="1" cellpadding="1" width="100%" border="1">
      <tr>
        <td>开始时间
          <asp:TextBox ID="tbx_begintime" onfocus="setday(this);" runat="server" ReadOnly="True" />
          <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" Display="Dynamic" ControlToValidate="tbx_begintime" />结束时间
          <asp:TextBox ID="tbx_endtime" onfocus="setday(this);" runat="server" ReadOnly="True" />
          <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*" ControlToValidate="tbx_endtime" />
          <asp:RadioButton ID="rbtn_thisweek" onclick="quickseldate('week');" runat="server" GroupName="quickselect" Text="本周" /> <asp:RadioButton ID="rbtn_thismonth" onclick="quickseldate('month');" runat="server" GroupName="quickselect" Text="本月" />
          <asp:Button ID="btn_OK" runat="server" Text="确定" />
        </td>
      </tr>
      <tr>
        <td>
          <asp:DataGrid ID="dgrd_sellman" runat="server" AutoGenerateColumns="False" AllowPaging="True" Width="100%">
            <Columns>
              <asp:TemplateColumn HeaderText="销售人员姓名">
                <ItemTemplate>
                  <%# ((DataRowView)Container.DataItem).Row.GetChildRows("staffid_realname")[0]["realname"].ToString()%>
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:TemplateColumn HeaderText="接触次数">
                <ItemTemplate>
                  <a href='<%# "sellmancontact.aspx?SellmanID=" + ((DataRowView)Container.DataItem)["sellmanid"] + "&Begintime=" + begintime.ToShortDateString() + "&Endtime=" + endtime.ToShortDateString() + "&type=all"%>' target="_blank"><%# ((DataRowView)Container.DataItem).Row.GetChildRows("sellman_contact").Length%> </a>
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:TemplateColumn HeaderText="拜访次数">
                <ItemTemplate>
                  <a href='<%# "sellmancontact.aspx?SellmanID=" + ((DataRowView)Container.DataItem)["sellmanid"] + "&Begintime=" + begintime.ToShortDateString() + "&Endtime=" + endtime.ToShortDateString() + "&type=callin"%>' target="_blank"><%# ((DataRowView)Container.DataItem).Row.GetChildRows("sellman_callincontact").Length%> </a>
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:TemplateColumn HeaderText="新发现客户">
                <ItemTemplate>
                  <a href='<%# "sellmanclient.aspx?SellmanID=" + ((DataRowView)Container.DataItem)["sellmanid"] + "&Begintime=" + begintime.ToShortDateString() + "&Endtime=" + endtime.ToShortDateString() + "&type=all"%>' target="_blank"><%# ((DataRowView)Container.DataItem).Row.GetChildRows("sellman_newclient").Length%> </a>
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:TemplateColumn HeaderText="新增3星以上客户">
                <ItemTemplate>
                  <a href='<%# "sellmanclient.aspx?SellmanID=" + ((DataRowView)Container.DataItem)["sellmanid"] + "&Begintime=" + begintime.ToShortDateString() + "&Endtime=" + endtime.ToShortDateString() + "&type=3stars"%>' target="_blank"><%# ((DataRowView)Container.DataItem).Row.GetChildRows("sellman_new3client").Length%> </a>
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:TemplateColumn HeaderText="发生费用">
                <ItemTemplate>
                  <a href='<%# "sellmanfee.aspx?SellmanID=" + ((DataRowView)Container.DataItem)["sellmanid"] + "&Begintime=" + begintime.ToShortDateString() + "&Endtime=" + endtime.ToShortDateString() %>' target="_blank"><%# ((DataRowView)Container.DataItem)["Fee"].ToString()%> </a>
                </ItemTemplate>
              </asp:TemplateColumn>
            </Columns>
            <PagerStyle HorizontalAlign="Right" Mode="NumericPages" />
          </asp:DataGrid>
        </td>
      </tr>
    </table>
  </form>
</body>
</html>
